import React, { Component } from 'react'

// #1 点击按钮，绑定事件
// #2 让数字再原来的基础上（获取原来的数字）
// #3 +1

export default class App extends Component {
  state = {
    count: 0,
    age: 18,
  }
  handleClick = () => {
    // this.state.count += 1
    // 数据确实变了，视图没更新
    // console.log(this.state.count)
    this.setState({ count: this.state.count + 1 })
  }
  render() {
    return (
      <div style={{ textAlign: 'center' }}>
        <p>age: {this.state.age}</p>
        <h3>计数器：{this.state.count}</h3>
        <button onClick={this.handleClick}>+1</button>
      </div>
    )
  }
}
